package com.wmuj.mapper;

import com.wmuj.pojo.Dept;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.Mapping;

import java.util.List;

@Mapper
public interface DeptMapper {
    //查询所有的部门数据
    @Select("SELECT id, name, create_time, update_time  FROM dept order by  update_time DESC;")
    List<Dept> findAll();

    //根据id删除部门数据
    @Delete("delete from dept where id = #{id}")
    void delete(Integer id);

    //新增数据
    @Insert("insert into dept(name, create_time, update_time) values(#{name},#{createTime},#{updateTime})")
    void add(Dept dept);

    //根据id查询部门数据
    @Select("select id, name, create_time, update_time from dept where id = #{id}")
    Dept findById(Integer id);

    //根据id更新部门数据
    @Update("UPDATE dept SET name = #{name}, update_time = #{updateTime} WHERE id = #{id};")
    void update(Dept dept);
}
